home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / Main.bin / ImageConsumer.java < prev    next >
Text File  |  1998-09-22  |  7KB  |  184 lines

  1. /*
  2.  * @(#)ImageConsumer.java    1.13 98/07/01
  3.  *
  4.  * Copyright 1995-1998 by Sun Microsystems, Inc.,
  5.  * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
  6.  * All rights reserved.
  7.  * 
  8.  * This software is the confidential and proprietary information
  9.  * of Sun Microsystems, Inc. ("Confidential Information").  You
  10.  * shall not disclose such Confidential Information and shall use
  11.  * it only in accordance with the terms of the license agreement
  12.  * you entered into with Sun.
  13.  */
  14.  
  15. package java.awt.image;
  16.  
  17. import java.util.Hashtable;
  18.  
  19. /**
  20.  * The interface for objects expressing interest in image data through
  21.  * the ImageProducer interfaces.  When a consumer is added to an image
  22.  * producer, the producer delivers all of the data about the image
  23.  * using the method calls defined in this interface.
  24.  *
  25.  * @see ImageProducer
  26.  *
  27.  * @version    1.13 07/01/98
  28.  * @author     Jim Graham
  29.  */
  30. public interface ImageConsumer {
  31.     /**
  32.      * The dimensions of the source image are reported using the
  33.      * setDimensions method call.
  34.      */
  35.     void setDimensions(int width, int height);
  36.  
  37.     /**
  38.      * Sets the extensible list of properties associated with this image.
  39.      */
  40.     void setProperties(Hashtable props);
  41.  
  42.     /**
  43.      * The ColorModel object used for the majority of
  44.      * the pixels reported using the setPixels method
  45.      * calls.  Note that each set of pixels delivered using setPixels
  46.      * contains its own ColorModel object, so no assumption should
  47.      * be made that this model will be the only one used in delivering
  48.      * pixel values.  A notable case where multiple ColorModel objects
  49.      * may be seen is a filtered image when for each set of pixels
  50.      * that it filters, the filter
  51.      * determines  whether the
  52.      * pixels can be sent on untouched, using the original ColorModel,
  53.      * or whether the pixels should be modified (filtered) and passed
  54.      * on using a ColorModel more convenient for the filtering process.
  55.      * @see ColorModel
  56.      */
  57.     void setColorModel(ColorModel model);
  58.  
  59.     /**
  60.      * The ImageProducer can deliver the pixels in any order, but
  61.      * the ImageConsumer may be able to scale or convert the pixels
  62.      * to the destination ColorModel more efficiently or with higher
  63.      * quality if it knows some information about how the pixels will
  64.      * be delivered up front.  The setHints method should be called
  65.      * before any calls to any of the setPixels methods with a bit mask
  66.      * of hints about the manner in which the pixels will be delivered.
  67.      * If the ImageProducer does not follow the guidelines for the
  68.      * indicated hint, the results are undefined.
  69.      */
  70.     void setHints(int hintflags);
  71.  
  72.     /**
  73.      * The pixels will be delivered in a random order.  This tells the
  74.      * ImageConsumer not to use any optimizations that depend on the
  75.      * order of pixel delivery, which should be the default assumption
  76.      * in the absence of any call to the setHints method.
  77.      * @see #setHints
  78.      */
  79.     int RANDOMPIXELORDER = 1;
  80.  
  81.     /**
  82.      * The pixels will be delivered in top-down, left-to-right order.
  83.      * @see #setHints
  84.      */
  85.     int TOPDOWNLEFTRIGHT = 2;
  86.  
  87.     /**
  88.      * The pixels will be delivered in (multiples of) complete scanlines
  89.      * at a time.
  90.      * @see #setHints
  91.      */
  92.     int COMPLETESCANLINES = 4;
  93.  
  94.     /**
  95.      * The pixels will be delivered in a single pass.  Each pixel will
  96.      * appear in only one call to any of the setPixels methods.  An
  97.      * example of an image format which does not meet this criterion
  98.      * is a progressive JPEG image which defines pixels in multiple
  99.      * passes, each more refined than the previous.
  100.      * @see #setHints
  101.      */
  102.     int SINGLEPASS = 8;
  103.  
  104.     /**
  105.      * The image contain a single static image.  The pixels will be defined
  106.      * in calls to the setPixels methods and then the imageComplete method
  107.      * will be called with the STATICIMAGEDONE flag after which no more
  108.      * image data will be delivered.  An example of an image type which
  109.      * would not meet these criteria would be the output of a video feed,
  110.      * or the representation of a 3D rendering being manipulated
  111.      * by the user.  The end of each frame in those types of images will
  112.      * be indicated by calling imageComplete with the SINGLEFRAMEDONE flag.
  113.      * @see #setHints
  114.      * @see #imageComplete
  115.      */
  116.     int SINGLEFRAME = 16;
  117.  
  118.     /**
  119.      * The pixels of the image are delivered using one or more calls
  120.      * to the setPixels method.  Each call specifies the location and
  121.      * size of the rectangle of source pixels that are contained in
  122.      * the array of pixels.  The specified ColorModel object should
  123.      * be used to convert the pixels into their corresponding color
  124.      * and alpha components.  Pixel (m,n) is stored in the pixels array
  125.      * at index (n * scansize + m + off).  The pixels delivered using
  126.      * this method are all stored as bytes.
  127.      * @see ColorModel
  128.      */
  129.     void setPixels(int x, int y, int w, int h,
  130.            ColorModel model, byte pixels[], int off, int scansize);
  131.  
  132.     /**
  133.      * The pixels of the image are delivered using one or more calls
  134.      * to the setPixels method.  Each call specifies the location and
  135.      * size of the rectangle of source pixels that are contained in
  136.      * the array of pixels.  The specified ColorModel object should
  137.      * be used to convert the pixels into their corresponding color
  138.      * and alpha components.  Pixel (m,n) is stored in the pixels array
  139.      * at index (n * scansize + m + off).  The pixels delivered using
  140.      * this method are all stored as ints.
  141.      * @see ColorModel
  142.      */
  143.     void setPixels(int x, int y, int w, int h,
  144.            ColorModel model, int pixels[], int off, int scansize);
  145.  
  146.     /**
  147.      * The imageComplete method is called when the ImageProducer is
  148.      * finished delivering all of the pixels that the source image
  149.      * contains, or when a single frame of a multi-frame animation has
  150.      * been completed, or when an error in loading or producing the
  151.      * image has occured.  The ImageConsumer should remove itself from the
  152.      * list of consumers registered with the ImageProducer at this time,
  153.      * unless it is interested in successive frames.
  154.      * @see ImageProducer#removeConsumer
  155.      */
  156.     void imageComplete(int status);
  157.  
  158.     /**
  159.      * An error was encountered while producing the image.
  160.      * @see #imageComplete
  161.      */
  162.     int IMAGEERROR = 1;
  163.  
  164.     /**
  165.      * One frame of the image is complete but there are more frames
  166.      * to be delivered.
  167.      * @see #imageComplete
  168.      */
  169.     int SINGLEFRAMEDONE = 2;
  170.  
  171.     /**
  172.      * The image is complete and there are no more pixels or frames
  173.      * to be delivered.
  174.      * @see #imageComplete
  175.      */
  176.     int STATICIMAGEDONE = 3;
  177.  
  178.     /**
  179.      * The image creation process was deliberately aborted.
  180.      * @see #imageComplete
  181.      */
  182.     int IMAGEABORTED = 4;
  183. }
  184.